package _06_huffmanTree;

// 二叉树的静态三叉链表结点类
public class TriElement {
    
    // 数据域
    int data;
    // 父母结点和左、右孩子结点下标
    int parent, left, right;
    
    // 构造元素值为data的结点
    public TriElement(int data, int parent, int left, int right) {
        this.data = data;
        this.parent = parent;
        this.left = left;
        this.right = right;
    }
    
    // 构造无父母的叶子结点
    public TriElement(int data) {
        this.data = data;
    }
    
    // 返回结点的描述字符串，形式为"(,)"
    public String toString() {
        return "(" + data + ", " + parent + ", " + left + ", " + right + ")";
    }
    
    // 判断是否叶子结点
    public boolean isLeaf() {
        return left == -1 && right == -1;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}
